package com.laotou99.wmsjjj.wmsjjj;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.redisson.Redisson;
import org.redisson.config.Config;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.util.Assert;

import com.google.common.collect.Lists;

@SpringBootApplication
public class WmsjjjApplication {

	private final ApplicationContext applicationContext;
	private static ConfigurableApplicationContext configurableApplicationContext;
	
	public WmsjjjApplication(ApplicationContext applicationContext) {
		this.applicationContext = applicationContext;
	}
	
	public static void main(String[] args) {
		configurableApplicationContext = SpringApplication.run(WmsjjjApplication.class, args);
		
		new Thread(new Runnable() {
			@Override
			public void run() {
				System.out.println("Other DB"); 
			}
		}).start();
		
	}
	
	public static Object getBean(String beanName) {
		return configurableApplicationContext.getBean(beanName);
	}
	
	@Bean
	public Redisson redisson() {
		Config config = new Config();
		config.useSingleServer().setAddress("redis://127.0.0.1:6379").setDatabase(0);
		return (Redisson)Redisson.create(config);
	}
}

//用于启动时测试某些功能
class TestAA1{
	
	
	public TestAA1() {
		System.out.println("TestAA1()");
		Assert.isTrue(StringUtils.isEmpty(""), "no name");
	}
	
	public void Test1() {
		List li1 = Lists.newArrayList();
		
	}
	
}